
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>LammpsIO &#8212; LammpsIO 1.0 documentation</title>
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">LammpsIO 1.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Module code</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <h1>Source code for LammpsIO</h1><div class="highlight"><pre>
<span></span><span class="c1"># =*= coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot;LammpsIO</span>
<span class="sd">Created on 21 September 2018</span>
<span class="sd">@author: Robert Ivancic</span>

<span class="sd">This module was created to facilitate input and output of LAMMPS</span>
<span class="sd">trajectory files in dump and netCDF (AMBER) format.</span>

<span class="sd">Notes</span>
<span class="sd">-----</span>
<span class="sd">  We plan to add a log reading functionality to this module soon.</span>

<span class="sd">&quot;&quot;&quot;</span> 

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">from</span> <span class="nn">netCDF4</span> <span class="k">import</span> <span class="n">Dataset</span>
<span class="kn">from</span> <span class="nn">netCDF4</span> <span class="k">import</span> <span class="n">stringtochar</span>

<div class="viewcode-block" id="NetCDFIO"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO">[docs]</a><span class="k">class</span> <span class="nc">NetCDFIO</span><span class="p">:</span>
  <span class="sd">&quot;&quot;&quot;Input and output of LAMMPS trajectories in NetCDF (AMBER).</span>

<span class="sd">  This class inputs and outputs individual frames from an AMBER</span>
<span class="sd">  format molecular dynamics trajectory. More on AMBER can be found</span>
<span class="sd">  here: http://ambermd.org/netcdf/nctraj.xhtml. More on NetCDF can</span>
<span class="sd">  be found here: https://en.wikipedia.org/wiki/NetCDF. There are two</span>
<span class="sd">  major advantages to this output format over standard dump files.</span>
<span class="sd">  First, these files are in binary format and thus, use about 1/3 of</span>
<span class="sd">  the space of standard dump files. Second, reading standard dump files</span>
<span class="sd">  must be done sequentially. With NetCDF you may obtain data from any</span>
<span class="sd">  frame of interest *f* instantly by simply selecting that frame in the</span>
<span class="sd">  data array. The major disadvantage of this format is that it assumes</span>
<span class="sd">  a constant number of particles throughout a simulation or experiment.</span>
<span class="sd">  Particles are assumed to be ordered by their ids.</span>

<span class="sd">  &quot;&quot;&quot;</span>

  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__sett</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setDataCol</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeO</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numDims</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numFrames</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numParts</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__gett</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getBB</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getPos</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getDataCol</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeI</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_vars</span> <span class="o">=</span> <span class="p">[]</span>

<div class="viewcode-block" id="NetCDFIO.OpenO"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.OpenO">[docs]</a>  <span class="k">def</span> <span class="nf">OpenO</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">nc_file_name</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Opens NetCDF file for output.</span>
<span class="sd">    </span>
<span class="sd">    Opens a NetCDF file of nc_file_name for writing (output).</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    nc_file_name : str</span>
<span class="sd">      Name of netCDF file you wish to write to.</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot set input and output in same instance&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot open file twice!&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># Conventions</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="n">nc_file_name</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s1">&#39;NETCDF4&#39;</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">Conventions</span> <span class="o">=</span> <span class="s1">&#39;AMBER&#39;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">ConventionVersion</span> <span class="o">=</span> <span class="s1">&#39;1.0&#39;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">program</span> <span class="o">=</span><span class="s1">&#39;LammpsPy.py&#39;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">programVersion</span> <span class="o">=</span> <span class="s1">&#39;1.0&#39;</span>

    <span class="c1"># Dimensions except number of particles</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;spatial&#39;</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;cell_spatial&#39;</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;cell_angular&#39;</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;label&#39;</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>

    <span class="c1"># Preliminary variables</span>
    <span class="n">char_sp_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;char spatial&#39;</span><span class="p">,</span>
      <span class="s1">&#39;S1&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;spatial&#39;</span><span class="p">))</span>
    <span class="n">char_sp_var</span><span class="p">[:]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;x&#39;</span><span class="p">,</span><span class="s1">&#39;y&#39;</span><span class="p">,</span><span class="s1">&#39;z&#39;</span><span class="p">]</span>
    <span class="n">char_csp_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;char cell_spatial&#39;</span><span class="p">,</span>
      <span class="s1">&#39;S1&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;cell_spatial&#39;</span><span class="p">))</span>
    <span class="n">char_csp_var</span><span class="p">[:]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span><span class="s1">&#39;b&#39;</span><span class="p">,</span><span class="s1">&#39;c&#39;</span><span class="p">]</span>
    <span class="n">char_sp_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;char cell_angular&#39;</span><span class="p">,</span>
      <span class="s1">&#39;S1&#39;</span><span class="p">,(</span><span class="s1">&#39;cell_angular&#39;</span><span class="p">,</span><span class="s1">&#39;label&#39;</span><span class="p">))</span>
    <span class="n">char_sp_var</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">stringtochar</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="s1">&#39;alpha&#39;</span><span class="p">,</span><span class="s1">&#39;beta&#39;</span><span class="p">,</span><span class="s1">&#39;gamma&#39;</span><span class="p">]))</span>
  
    <span class="c1"># notes OpenO has been run</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="NetCDFIO.Sett"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.Sett">[docs]</a>  <span class="k">def</span> <span class="nf">Sett</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Sets timestep t of frame f</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>
<span class="sd">    t : int</span>
<span class="sd">      timestep at frame f</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__sett</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__t_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="s1">&#39;f4&#39;</span><span class="p">,</span>
        <span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__t_var</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;LJ&#39;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__t_var</span><span class="p">[</span><span class="n">f</span><span class="p">]</span> <span class="o">=</span> <span class="n">t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__sett</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="NetCDFIO.SetBB"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.SetBB">[docs]</a>  <span class="k">def</span> <span class="nf">SetBB</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">bb_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Sets box boundaries of frame f. These are formatted as</span>
<span class="sd">    [low_x, high_x] for each dimension.</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>
<span class="sd">    bb_t : numpy array (dimension,2)</span>
<span class="sd">      box boundaries at time t</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__cell_o_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;cell_origin&#39;</span><span class="p">,</span> 
        <span class="s1">&#39;f4&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">,</span><span class="s1">&#39;cell_spatial&#39;</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__cell_o_var</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;LJ&#39;</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__cell_l_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;cell_lengths&#39;</span><span class="p">,</span> 
        <span class="s1">&#39;f4&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">,</span><span class="s1">&#39;cell_spatial&#39;</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__cell_l_var</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;LJ&#39;</span>  
      <span class="bp">self</span><span class="o">.</span><span class="n">__cell_a_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;cell_angles&#39;</span><span class="p">,</span> 
        <span class="s1">&#39;f4&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">,</span><span class="s1">&#39;cell_angular&#39;</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__cell_a_var</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;degree&#39;</span>

    <span class="c1"># Sets dimension of output</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">3</span><span class="p">:</span>
        <span class="nb">print</span> <span class="s1">&#39;ERROR: bb_t.shape[0] != 2 or 3&#39;</span>
        <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">dimension</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span>

    <span class="c1"># Adds a 3rd dimension for 2D data</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">!=</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: dimension != bb_t.shape[0]&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
      <span class="n">bb_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">bb_t</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="o">-</span><span class="mi">10</span><span class="o">**</span><span class="p">(</span><span class="o">-</span><span class="mi">6</span><span class="p">),</span><span class="mi">10</span><span class="o">**</span><span class="p">(</span><span class="o">-</span><span class="mi">6</span><span class="p">)]])))</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__cell_o_var</span><span class="p">[</span><span class="n">f</span><span class="p">]</span> <span class="o">=</span> <span class="n">bb_t</span><span class="p">[:,</span><span class="mi">0</span><span class="p">]</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__cell_l_var</span><span class="p">[</span><span class="n">f</span><span class="p">]</span> <span class="o">=</span> <span class="n">bb_t</span><span class="p">[:,</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="n">bb_t</span><span class="p">[:,</span><span class="mi">0</span><span class="p">]</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__cell_a_var</span><span class="p">[</span><span class="n">f</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="o">*</span><span class="mi">90</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="NetCDFIO.SetPos"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.SetPos">[docs]</a>  <span class="k">def</span> <span class="nf">SetPos</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">pos_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Sets particle positions (coordinates) at frame f</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>
<span class="sd">    pos_t : numpy array (number of particles, dimension)</span>
<span class="sd">      particle positions (coordinates) at frame f</span>
<span class="sd">      </span>
<span class="sd">    &quot;&quot;&quot;</span> 
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setDataCol</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;atom&#39;</span><span class="p">,</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__c_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;coordinates&#39;</span><span class="p">,</span> <span class="s1">&#39;f4&#39;</span><span class="p">,</span>
        <span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">,</span><span class="s1">&#39;atom&#39;</span><span class="p">,</span><span class="s1">&#39;spatial&#39;</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__c_var</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;LJ&#39;</span>

    <span class="c1"># Sets dimension of output</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">3</span><span class="p">:</span>
        <span class="nb">print</span> <span class="s1">&#39;ERROR: pos_t.shape[1] != 2 or 3&#39;</span>
        <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">dimension</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span>

    <span class="c1"># Adds a 3rd dimension for 2D data</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">!=</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: dimension != pos_t.shape[1]&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
      <span class="n">pos_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">((</span><span class="n">pos_t</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])])</span><span class="o">.</span><span class="n">T</span><span class="p">))</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__c_var</span><span class="p">[</span><span class="n">f</span><span class="p">]</span> <span class="o">=</span> <span class="n">pos_t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="NetCDFIO.SetDataCol"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.SetDataCol">[docs]</a>  <span class="k">def</span> <span class="nf">SetDataCol</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">data_col_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Sets a data column at frame f</span>

<span class="sd">    A data column is a way of storing values that are associated with </span>
<span class="sd">    every particle in a simulation or experiment at every timestep.</span>
<span class="sd">    Examples include: J2, D2min, p_{hop}, or softness of every particle</span>
<span class="sd">    at every timestep. This sets a data column for time t.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>
<span class="sd">    label : str</span>
<span class="sd">      data column name</span>
<span class="sd">    data_col_t : numpy array (number of particles,)</span>
<span class="sd">      data column values for all particles at frame f</span>
<span class="sd">      </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setDataCol</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;atom&#39;</span><span class="p">,</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
    <span class="k">if</span> <span class="n">label</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_vars</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span>
        <span class="n">label</span><span class="p">,</span> <span class="s1">&#39;f4&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;frame&#39;</span><span class="p">,</span><span class="s1">&#39;atom&#39;</span><span class="p">)))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_vars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;LJ&#39;</span>
    <span class="n">idx_col</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">)</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
    <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_vars</span><span class="p">)[</span><span class="n">idx_col</span><span class="p">][</span><span class="n">f</span><span class="p">]</span> <span class="o">=</span> <span class="n">data_col_t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setDataCol</span> <span class="o">=</span> <span class="kc">True</span></div>

  <span class="c1"># Closes output file</span>
<div class="viewcode-block" id="NetCDFIO.CloseO"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.CloseO">[docs]</a>  <span class="k">def</span> <span class="nf">CloseO</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Closes output NetCDF file</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeO</span> <span class="o">=</span> <span class="kc">True</span></div>

  <span class="c1"># Opens input file</span>
<div class="viewcode-block" id="NetCDFIO.OpenI"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.OpenI">[docs]</a>  <span class="k">def</span> <span class="nf">OpenI</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">nc_file_name</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Opens NetCDF file for input.</span>
<span class="sd">    </span>
<span class="sd">    Opens a NetCDF file of nc_file_name for reading (input).</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    nc_file_name : str</span>
<span class="sd">      Name of netCDF file you wish to read from.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot open file twice!&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot set input and output in same instance&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="n">nc_file_name</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s1">&#39;NETCDF4&#39;</span><span class="p">)</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span> <span class="o">=</span> <span class="kc">True</span></div>

  <span class="c1"># returns number of dimensions</span>
<div class="viewcode-block" id="NetCDFIO.NumDims"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.NumDims">[docs]</a>  <span class="k">def</span> <span class="nf">NumDims</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Outputs number of dimensions of current simulation being read.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    d : int</span>
<span class="sd">      Number of dimensions of simulation you are reading.</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before num functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numDims</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="c1"># Checks if has attribute dimensions. If it does takes that</span>
    <span class="c1"># number to be ground truth. Otherwise assumes 3D.</span>
    <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="p">,</span> <span class="s1">&#39;dimension&#39;</span><span class="p">):</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">dimension</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="mi">3</span>

    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span></div>

  <span class="c1"># returns number of frames</span>
<div class="viewcode-block" id="NetCDFIO.NumFrames"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.NumFrames">[docs]</a>  <span class="k">def</span> <span class="nf">NumFrames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Outputs number of frames of current simulation being read.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    n_f : int</span>
<span class="sd">      Number of frames of simulation you are reading.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before num functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numFrames</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">n_f</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">dimensions</span><span class="p">[</span><span class="s1">&#39;frame&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">size</span>
    <span class="k">return</span> <span class="n">n_f</span></div>

  <span class="c1"># returns number of particles</span>
<div class="viewcode-block" id="NetCDFIO.NumParts"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.NumParts">[docs]</a>  <span class="k">def</span> <span class="nf">NumParts</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Outputs number of particles of current simulation being read.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    n_p : int</span>
<span class="sd">      Number of particles of simulation you are reading.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before num functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numParts</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">n_p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">dimensions</span><span class="p">[</span><span class="s1">&#39;atom&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">size</span>
    <span class="k">return</span> <span class="n">n_p</span></div>

  <span class="c1"># returns timestep for frame f</span>
<div class="viewcode-block" id="NetCDFIO.Gett"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.Gett">[docs]</a>  <span class="k">def</span> <span class="nf">Gett</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Gets timestep t of frame f</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    t : int</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__gett</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;time&#39;</span><span class="p">][</span><span class="n">f</span><span class="p">]</span>
    <span class="k">return</span> <span class="n">t</span></div>

  <span class="c1"># returns box boundaries for frame f</span>
<div class="viewcode-block" id="NetCDFIO.GetBB"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.GetBB">[docs]</a>  <span class="k">def</span> <span class="nf">GetBB</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Gets box boundaries (BB) of frame f. These are formatted as</span>
<span class="sd">    [low_x, high_x] for each dimension.</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    bb_t : numpy array (dimension,2)</span>
<span class="sd">      box boundaries at time t</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getBB</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">bb_L</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;cell_origin&#39;</span><span class="p">][</span><span class="n">f</span><span class="p">]</span>
    <span class="n">bb_R</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;cell_lengths&#39;</span><span class="p">][</span><span class="n">f</span><span class="p">]</span> <span class="o">+</span> <span class="n">bb_L</span>

    <span class="n">bb_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">bb_L</span><span class="p">,</span> <span class="n">bb_R</span><span class="p">))</span><span class="o">.</span><span class="n">T</span>

    <span class="c1"># Gets dimensions of array</span>
    <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NumDims</span><span class="p">()</span>

    <span class="k">return</span> <span class="n">bb_t</span><span class="p">[:</span><span class="n">d</span><span class="p">]</span></div>

  <span class="c1"># returns atom coordinates for frame f</span>
<div class="viewcode-block" id="NetCDFIO.GetPos"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.GetPos">[docs]</a>  <span class="k">def</span> <span class="nf">GetPos</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Gets particle positions (coordinates) at frame f</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    pos_t : numpy array (number of particles, dimension)</span>
<span class="sd">      particle positions (coordinates) at frame f</span>
<span class="sd">      </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getPos</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">pos_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;coordinates&#39;</span><span class="p">][</span><span class="n">f</span><span class="p">]</span>

    <span class="c1"># Gets dimensions of array</span>
    <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NumDims</span><span class="p">()</span>

    <span class="k">return</span> <span class="n">pos_t</span><span class="p">[:,:</span><span class="nb">int</span><span class="p">(</span><span class="n">d</span><span class="p">)]</span></div>

  <span class="c1"># returns box boundaries for frame f</span>
<div class="viewcode-block" id="NetCDFIO.GetDataCol"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.GetDataCol">[docs]</a>  <span class="k">def</span> <span class="nf">GetDataCol</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">label</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Sets a data column at frame f</span>

<span class="sd">    A data column is a way of storing values that are associated with </span>
<span class="sd">    every particle in a simulation or experiment at every timestep.</span>
<span class="sd">    Examples include: J2, D2min, p_{hop}, or softness of every particle</span>
<span class="sd">    at every timestep. This gets a data column for time t.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    f : int</span>
<span class="sd">      frame number</span>
<span class="sd">    label : str</span>
<span class="sd">      data column name</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    data_col_t : numpy array (number of particles,)</span>
<span class="sd">      data column values for all particles at frame f</span>
<span class="sd">      </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getDataCol</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">data_col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="n">label</span><span class="p">][</span><span class="n">f</span><span class="p">]</span>
    <span class="k">return</span> <span class="n">data_col</span></div>

  <span class="c1"># Closes output file</span>
<div class="viewcode-block" id="NetCDFIO.CloseI"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.NetCDFIO.CloseI">[docs]</a>  <span class="k">def</span> <span class="nf">CloseI</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Closes input NetCDF file</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__nc_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeI</span> <span class="o">=</span> <span class="kc">True</span></div></div>



<div class="viewcode-block" id="DumpIO"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO">[docs]</a><span class="k">class</span> <span class="nc">DumpIO</span><span class="p">:</span>
  <span class="sd">&quot;&quot;&quot; Input and output LAMMPS trajectories in dump (lammpstrj) format.</span>

<span class="sd">  This class inputs and outputs frames of a LAMMPS trajectory. It does</span>
<span class="sd">  this *sequentially*, i.e. it reads (writes) in a single frame of a dump</span>
<span class="sd">  (lammpstrj) trajectory at a time starting at frame 0. This approach has</span>
<span class="sd">  two benefits to reading in an entire trajectory at once both steming </span>
<span class="sd">  from the fact that it is more memory efficient. First (and most </span>
<span class="sd">  importantly), python has memory limits that are easily reached if </span>
<span class="sd">  the number of particles times the number of frames loaded in at one</span>
<span class="sd">  time is greater than 25,000,000. Practically, it is very easy to hit</span>
<span class="sd">  this limit when running large or long time simulations. Second,</span>
<span class="sd">  this approach is generally faster than loading in all frames at once</span>
<span class="sd">  as it requires much less time to allocate memory.</span>
<span class="sd">  &quot;&quot;&quot;</span>

  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__sett</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setID</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setDataCol</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([])</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__writeNextFrame</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setIDWarning</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeO</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__loadNextFrame</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numDims</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numFrames</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__numParts</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__gett</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getBB</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getPos</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getDataCol</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeI</span> <span class="o">=</span> <span class="kc">False</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span> <span class="o">=</span> <span class="p">[]</span>

<div class="viewcode-block" id="DumpIO.OpenO"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.OpenO">[docs]</a>  <span class="k">def</span> <span class="nf">OpenO</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dump_file_name</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Opens dump file for output.</span>

<span class="sd">    Opens a dump (lammpstrj) file of name dumpe_file_name for writing</span>
<span class="sd">    (output). </span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot set input and output in same instance&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot open file twice!&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># Opens file for writing</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">dump_file_name</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>

    <span class="c1"># notes OpenO has been run</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.Sett"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.Sett">[docs]</a>  <span class="k">def</span> <span class="nf">Sett</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Sets timestep t of current frame</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    t : int</span>
<span class="sd">      timestep of current frame</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__t</span> <span class="o">=</span> <span class="n">t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__sett</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.SetBB"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.SetBB">[docs]</a>  <span class="k">def</span> <span class="nf">SetBB</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bb_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Sets box boundaries (BB) of current frame</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    bb_t : numpy array (dimension,2)</span>
<span class="sd">      box boundaries of current frame</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># Sets dimension of output</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">3</span><span class="p">:</span>
        <span class="nb">print</span> <span class="s1">&#39;ERROR: bb_t.shape[0] != 2 or 3&#39;</span>
        <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

    <span class="c1"># Adds a 3rd dimension for 2D data</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">!=</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: dimension != bb_t.shape[0]&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
      <span class="n">bb_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">bb_t</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="o">-</span><span class="mi">10</span><span class="o">**</span><span class="p">(</span><span class="o">-</span><span class="mi">6</span><span class="p">),</span><span class="mi">10</span><span class="o">**</span><span class="p">(</span><span class="o">-</span><span class="mi">6</span><span class="p">)]])))</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__bb_t</span> <span class="o">=</span> <span class="n">bb_t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.SetID"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.SetID">[docs]</a>  <span class="k">def</span> <span class="nf">SetID</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">id_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Sets particle ids of current frame</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    id_t : numpy array (number of particles,)</span>
<span class="sd">      particle ids of each particle of current frame</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span> <span class="o">=</span> <span class="n">id_t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setID</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.SetPos"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.SetPos">[docs]</a>  <span class="k">def</span> <span class="nf">SetPos</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pos_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Sets particle positions of current frame</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    pos_t : numpy array (number of particles, dimensions)</span>
<span class="sd">      particle positions (coordinates) of current frame in order of </span>
<span class="sd">      id_t</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># Sets dimension of output</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">3</span><span class="p">:</span>
        <span class="nb">print</span> <span class="s1">&#39;ERROR: pos_t.shape[1] != 2 or 3&#39;</span>
        <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>

    <span class="c1"># Adds a 3rd dimension for 2D data</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">!=</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: dimension != pos_t.shape[1]&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span> <span class="o">=</span> <span class="n">pos_t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.SetDataCol"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.SetDataCol">[docs]</a>  <span class="k">def</span> <span class="nf">SetDataCol</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">data_col_t</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Sets particle positions of current frame</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    label : str</span>
<span class="sd">      name of the data column</span>
<span class="sd">    data_col_t : numpy array (number of particles,)</span>
<span class="sd">      particle positions (coordinates) of current frame in order of </span>
<span class="sd">      id_t</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before set functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">label</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>

    <span class="c1"># Finds index of data column</span>
    <span class="n">idx_col</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">)</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
    <span class="k">while</span><span class="p">(</span><span class="n">idx_col</span> <span class="o">&gt;=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">)):</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">[</span><span class="n">idx_col</span><span class="p">]</span> <span class="o">=</span> <span class="n">data_col_t</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__setDataCol</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.WriteNextFrame"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.WriteNextFrame">[docs]</a>  <span class="k">def</span> <span class="nf">WriteNextFrame</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Writes the next frame to the dump file.</span>
<span class="sd">    </span>
<span class="sd">    Writes all timestep, box boundary, particle id, particle position,</span>
<span class="sd">    and data column information given in frame to file. Must use OpenO</span>
<span class="sd">    and Set functions before use.</span>

<span class="sd">    Warnings</span>
<span class="sd">    --------</span>
<span class="sd">    Will run without having set particle ids. Assumes particles in order</span>
<span class="sd">    from 1,...,(number of particles).</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">error_message</span> <span class="o">=</span> <span class="s1">&#39;ERROR: Incorrect input formatting. Ensure:</span><span class="se">\n\t</span><span class="s1">&#39;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenO before Write functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__sett</span><span class="p">:</span>
      <span class="nb">print</span> <span class="n">error_message</span> <span class="o">+</span> <span class="s1">&#39;Sett is used&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setBB</span><span class="p">:</span>
      <span class="nb">print</span> <span class="n">error_message</span> <span class="o">+</span> <span class="s1">&#39;SetBB is used&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setPos</span><span class="p">:</span>
      <span class="nb">print</span> <span class="n">error_message</span> <span class="o">+</span> <span class="s1">&#39;SetPos is used&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">)</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">):</span>
      <span class="nb">print</span> <span class="n">error_message</span><span class="o">+</span><span class="s1">&#39;All data columns are stored in each frame&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setID</span><span class="p">:</span>
      <span class="nb">print</span> <span class="n">error_message</span><span class="o">+</span><span class="s1">&#39;id_t.shape[0] == pos_t.shape[0]&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">elif</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setID</span><span class="p">:</span>
      <span class="c1"># Automatically assumes particles in order if ids not set</span>
      <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__setIDWarning</span><span class="p">:</span>
        <span class="nb">print</span> <span class="s1">&#39;WARNING: SetID function not used. Assuming particle ID&#39;</span>
        <span class="nb">print</span> <span class="s1">&#39;</span><span class="se">\t</span><span class="s1">is in order particles are in pos_t&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__setIDWarning</span> <span class="o">=</span> <span class="kc">True</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">+</span><span class="mi">1</span>
    <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">)):</span>
      <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">[</span><span class="n">col</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
        <span class="nb">print</span> <span class="n">error_message</span><span class="o">+</span><span class="s1">&#39;For data column &#39;</span><span class="o">+</span>\
              <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">[</span><span class="n">col</span><span class="p">])</span><span class="o">+</span><span class="s1">&#39;, &#39;</span><span class="o">+</span>\
              <span class="s1">&#39;col.shape[0] == pos_t.shape[0]&#39;</span>
        <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># Finds number of particles and dimension</span>
    <span class="n">n_p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
    <span class="n">bb_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__bb_t</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
      <span class="n">dim_str</span> <span class="o">=</span> <span class="s1">&#39;x y &#39;</span>
    <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span><span class="o">==</span><span class="mi">3</span><span class="p">:</span>
      <span class="n">dim_str</span> <span class="o">=</span> <span class="s1">&#39;x y z &#39;</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must have 2 or 3 dimensions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># Writes frame header</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;ITEM: TIMESTEP</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__t</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;ITEM: NUMBER OF ATOMS</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">n_p</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;ITEM: BOX BOUNDS</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
    <span class="n">bb_str_t</span> <span class="o">=</span> <span class="s1">&#39; </span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">lin</span><span class="p">)</span> <span class="k">for</span> <span class="n">lin</span> \
          <span class="ow">in</span> <span class="n">bb_t</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">str</span><span class="p">)])</span><span class="o">+</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">bb_str_t</span><span class="p">)</span>
    <span class="n">dataH_str</span> <span class="o">=</span> <span class="s1">&#39;ITEM: ATOMS &#39;</span><span class="o">+</span><span class="s1">&#39;id &#39;</span><span class="o">+</span><span class="n">dim_str</span><span class="o">+</span>\
          <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39; </span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">dataH_str</span><span class="p">)</span>

    <span class="c1"># Writes frame data</span>
    <span class="n">ids</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">str</span><span class="p">)</span>
    <span class="n">pos_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">str</span><span class="p">)</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
      <span class="n">dataCols_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">)</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">str</span><span class="p">)</span>
      <span class="n">data_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">ids</span><span class="p">,</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">dataCols_t</span><span class="p">))</span><span class="o">.</span><span class="n">T</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">data_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">ids</span><span class="p">,</span> <span class="n">pos_t</span><span class="o">.</span><span class="n">T</span><span class="p">))</span><span class="o">.</span><span class="n">T</span>
    <span class="n">data_str_t</span> <span class="o">=</span> <span class="s1">&#39; </span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">lin</span><span class="p">)</span> <span class="k">for</span> <span class="n">lin</span> <span class="ow">in</span> <span class="n">data_t</span><span class="p">])</span><span class="o">+</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data_str_t</span><span class="p">)</span></div>
    

<div class="viewcode-block" id="DumpIO.CloseO"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.CloseO">[docs]</a>  <span class="k">def</span> <span class="nf">CloseO</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Closes output file for dump</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeO</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.OpenI"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.OpenI">[docs]</a>  <span class="k">def</span> <span class="nf">OpenI</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dump_file_name</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Opens lammpstrj file for input</span>

<span class="sd">    Opens a dump (lammpstrj) file of name dump_file_name for reading</span>
<span class="sd">    (input)</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot open file twice!&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openO</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Cannot set input and output in same instance&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># Opens file for writing</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">dump_file_name</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.LoadNextFrame"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.LoadNextFrame">[docs]</a>  <span class="k">def</span> <span class="nf">LoadNextFrame</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Loads next frame in the dump (lammpstrj) file.</span>

<span class="sd">    Reads all timestep, box boundary, particle id, particle position, </span>
<span class="sd">    and data column information given in frame to file. Must use OpenI</span>
<span class="sd">    before use. Get functions may be used after this function.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Reads the header of dump file</span>
    <span class="n">line</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
    <span class="k">while</span> <span class="n">line</span><span class="p">[:</span><span class="mi">11</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;ITEM: ATOMS&#39;</span><span class="p">:</span>
      <span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
      <span class="k">if</span> <span class="n">line</span><span class="p">[:</span><span class="mi">16</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;ITEM: BOX BOUNDS&#39;</span><span class="p">:</span>
        <span class="n">bb_t</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
        <span class="k">while</span> <span class="n">line</span><span class="p">[:</span><span class="mi">5</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;ITEM:&#39;</span><span class="p">:</span>
          <span class="n">last_pos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">tell</span><span class="p">()</span>
          <span class="n">bb_t</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">())</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">float</span><span class="p">))</span>
          <span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="n">last_pos</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__bb_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">bb_t</span><span class="p">)</span>
        <span class="n">line</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
      <span class="k">if</span> <span class="n">line</span><span class="p">[:</span><span class="mi">14</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;ITEM: TIMESTEP&#39;</span><span class="p">:</span>
        <span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__t</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
      <span class="k">if</span> <span class="n">line</span><span class="p">[:</span><span class="mi">21</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;ITEM: NUMBER OF ATOMS&#39;</span><span class="p">:</span>
        <span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
        <span class="n">n_p</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>

    <span class="c1"># Obtains data columns of data</span>
    <span class="n">DataCols</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">11</span><span class="p">:]</span><span class="o">.</span><span class="n">split</span><span class="p">())</span>
    <span class="n">col_id</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">DataCols</span><span class="o">==</span><span class="s1">&#39;id&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
    <span class="n">col_x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">DataCols</span><span class="o">==</span><span class="s1">&#39;x&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
    <span class="n">col_y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">DataCols</span><span class="o">==</span><span class="s1">&#39;y&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
    <span class="k">if</span> <span class="s1">&#39;z&#39;</span> <span class="ow">in</span> <span class="n">DataCols</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="mi">3</span>
      <span class="n">col_z</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">DataCols</span><span class="o">==</span><span class="s1">&#39;z&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
      <span class="n">col_coordinates</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">col_x</span><span class="p">,</span> <span class="n">col_y</span><span class="p">,</span> <span class="n">col_z</span><span class="p">,</span> <span class="n">col_id</span><span class="p">])</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">=</span> <span class="mi">2</span>
      <span class="n">col_coordinates</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">col_x</span><span class="p">,</span> <span class="n">col_y</span><span class="p">,</span> <span class="n">col_id</span><span class="p">])</span>
    <span class="n">remove_cols</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="s1">&#39;id&#39;</span><span class="p">,</span><span class="s1">&#39;x&#39;</span><span class="p">,</span><span class="s1">&#39;y&#39;</span><span class="p">,</span><span class="s1">&#39;z&#39;</span><span class="p">])</span>
    <span class="n">DataCols_no_coordinates</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">setdiff1d</span><span class="p">(</span><span class="n">DataCols</span><span class="p">,</span><span class="n">remove_cols</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span> <span class="o">=</span> <span class="n">DataCols_no_coordinates</span>
    <span class="n">DataCols_idx</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">DataCols</span><span class="o">==</span><span class="n">col</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> \
          <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">])</span>
    <span class="n">n_DataCols</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="p">)</span>

    <span class="c1"># Obtains data from frame</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">n_p</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span><span class="p">))</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">n_p</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span> <span class="o">=</span> <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">n_p</span><span class="p">)</span> <span class="k">for</span> <span class="n">ii</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_DataCols</span><span class="p">)]</span>
    <span class="k">for</span> <span class="n">pp</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_p</span><span class="p">):</span>
      <span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
      <span class="n">data_pp</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
      
      <span class="c1"># Stores data</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="p">[</span><span class="n">pp</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data_pp</span><span class="p">[</span><span class="n">col_x</span><span class="p">])</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="p">[</span><span class="n">pp</span><span class="p">,</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data_pp</span><span class="p">[</span><span class="n">col_y</span><span class="p">])</span>
      <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span> <span class="o">!=</span> <span class="mi">2</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="p">[</span><span class="n">pp</span><span class="p">,</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data_pp</span><span class="p">[</span><span class="n">col_z</span><span class="p">])</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span><span class="p">[</span><span class="n">pp</span><span class="p">]</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">data_pp</span><span class="p">[</span><span class="n">col_id</span><span class="p">])</span>
      <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">DataCols_idx</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">[</span><span class="n">idx</span><span class="p">][</span><span class="n">pp</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data_pp</span><span class="p">[</span><span class="n">col</span><span class="p">])</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__loadNextFrame</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.NumDims"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.NumDims">[docs]</a>  <span class="k">def</span> <span class="nf">NumDims</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Outputs number of dimensions of current simulation being read.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    d : int</span>
<span class="sd">      Number of dimensions of simulation you are reading.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before num functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__loadNextFrame</span><span class="p">:</span>
      <span class="n">last_pos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">tell</span><span class="p">()</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">LoadNextFrame</span><span class="p">()</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="n">last_pos</span><span class="p">)</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__numDims</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__d</span></div>

<div class="viewcode-block" id="DumpIO.NumFrames"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.NumFrames">[docs]</a>  <span class="k">def</span> <span class="nf">NumFrames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Outputs number of frames of current simulation being read.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    n_f : int</span>
<span class="sd">      Number of frames of the simulation you are reading.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before num functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1"># stores current position in file and restarts read</span>
    <span class="c1"># loops through all lines in file to find ITEM: ATOMS</span>
    <span class="n">n_f</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">last_pos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">tell</span><span class="p">()</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">line</span><span class="p">[:</span><span class="mi">11</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;ITEM: ATOMS&#39;</span><span class="p">:</span>
        <span class="n">n_f</span> <span class="o">+=</span> <span class="mi">1</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="n">last_pos</span><span class="p">)</span>
    
    <span class="bp">self</span><span class="o">.</span><span class="n">__numFrames</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="k">return</span> <span class="n">n_f</span></div>

<div class="viewcode-block" id="DumpIO.NumPartsCurrentf"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.NumPartsCurrentf">[docs]</a>  <span class="k">def</span> <span class="nf">NumPartsCurrentf</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Outputs number of particles in current frame.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    n_p : int</span>
<span class="sd">      Number of particles in the current frame.</span>

<span class="sd">    Warnings</span>
<span class="sd">    --------</span>
<span class="sd">    If used without loading any frames, gives number of particles of</span>
<span class="sd">    first frame.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before num functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__loadNextFrame</span><span class="p">:</span>
      <span class="n">last_pos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">tell</span><span class="p">()</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">LoadNextFrame</span><span class="p">()</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="n">last_pos</span><span class="p">)</span>

    <span class="bp">self</span><span class="o">.</span><span class="n">__numParts</span> <span class="o">=</span> <span class="kc">True</span>

    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></div>

<div class="viewcode-block" id="DumpIO.Gett"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.Gett">[docs]</a>  <span class="k">def</span> <span class="nf">Gett</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Gets timestep t of current frame.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    t : int</span>
<span class="sd">      timestep of the current frame.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__gett</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__t</span>
    <span class="k">return</span> <span class="n">t</span></div>

<div class="viewcode-block" id="DumpIO.GetBB"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.GetBB">[docs]</a>  <span class="k">def</span> <span class="nf">GetBB</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Gets box boundary (BB) of current frame. These are formatted as</span>
<span class="sd">    [low_x, high_x] for each dimension.</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    bb_t : numpy array (dimension,2)</span>
<span class="sd">      box boundaries of current frame</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getBB</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">bb_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__bb_t</span>
    <span class="k">return</span> <span class="n">bb_t</span><span class="p">[:</span><span class="bp">self</span><span class="o">.</span><span class="n">__d</span><span class="p">]</span></div>

<div class="viewcode-block" id="DumpIO.GetID"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.GetID">[docs]</a>  <span class="k">def</span> <span class="nf">GetID</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Gets particle ids of current frame</span>

<span class="sd">    Returns</span>
<span class="sd">    ----------</span>
<span class="sd">    id_t : numpy array (number of particles,)</span>
<span class="sd">      particle ids of each particle of current frame</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getBB</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">id_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">int</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">id_t</span></div>

<div class="viewcode-block" id="DumpIO.GetPos"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.GetPos">[docs]</a>  <span class="k">def</span> <span class="nf">GetPos</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Gets particle positions (coordinates) of current frame</span>

<span class="sd">    Returns</span>
<span class="sd">    ----------</span>
<span class="sd">    pos_t : numpy array (number of particles, dimension)</span>
<span class="sd">      particle positions (coordinates) of each particle of current </span>
<span class="sd">      frame</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getPos</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="n">pos_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span>
    <span class="k">return</span> <span class="n">pos_t</span></div>

  <span class="c1"># returns box boundaries for current frame</span>
<div class="viewcode-block" id="DumpIO.GetDataCol"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.GetDataCol">[docs]</a>  <span class="k">def</span> <span class="nf">GetDataCol</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">label</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Gets data column of current frame</span>

<span class="sd">    A data column is a way of storing values that are associated with </span>
<span class="sd">    every particle in a simulation or experiment at every timestep.</span>
<span class="sd">    Examples include: J2, D2min, p_{hop}, or softness of every </span>
<span class="sd">    particle at every timestep. This gets a data column for the current</span>
<span class="sd">    frame in the dump file.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    label : str</span>
<span class="sd">      name of data column label</span>

<span class="sd">    Returns</span>
<span class="sd">    ----------</span>
<span class="sd">    id_t : numpy array (number of particles,)</span>
<span class="sd">      particle ids of each particle of current frame</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">__openI</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: Must use OpenI before get functions&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__getDataCol</span> <span class="o">=</span> <span class="kc">True</span>
    <span class="k">try</span><span class="p">:</span>
      <span class="n">data_col</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCols</span><span class="o">==</span><span class="n">label</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
      <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">[</span><span class="n">data_col</span><span class="p">]</span>
    <span class="k">except</span><span class="p">:</span>
      <span class="nb">print</span> <span class="s1">&#39;ERROR: label for data column not in dump file&#39;</span>
      <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">data</span></div>

  <span class="c1"># Closes output file</span>
<div class="viewcode-block" id="DumpIO.CloseI"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.CloseI">[docs]</a>  <span class="k">def</span> <span class="nf">CloseI</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Closes input (reading) dump file.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__dump_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__closeO</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="DumpIO.SortByID"><a class="viewcode-back" href="../LammpsIO.html#LammpsIO.DumpIO.SortByID">[docs]</a>  <span class="k">def</span> <span class="nf">SortByID</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Sorts particles of all arrays by their id</span>

<span class="sd">    Sorts pos_t, id_t, and data_col_t arrays so that </span>
<span class="sd">    id_t = range(n_p)</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># ranking of id values</span>
    <span class="n">ranks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span><span class="o">.</span><span class="n">argsort</span><span class="p">()</span>

    <span class="c1"># Performs sorting</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__id_t</span><span class="p">[</span><span class="n">ranks</span><span class="p">]</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__pos_t</span><span class="p">[</span><span class="n">ranks</span><span class="p">]</span>
    <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">)):</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">[</span><span class="n">col</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__DataCol_arrs</span><span class="p">[</span><span class="n">col</span><span class="p">][</span><span class="n">ranks</span><span class="p">]</span></div></div>

</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">LammpsIO 1.0 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >Module code</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2018, Robert J. S. Ivancic.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.0.
    </div>
  </body>
</html>